package net.borlis.sample.services.facade.ws.request;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author alex@borlis.net on 18.09.2014.
 */
@XmlRootElement
public class BookingConfigUpdateRequest {

    private String hotelProviderCode;
    private String flightProviderCode;
    private String strategyCode;

    public BookingConfigUpdateRequest() {
    }

    public BookingConfigUpdateRequest(String hotelProviderCode, String flightProviderCode, String strategyCode) {
        this.hotelProviderCode = hotelProviderCode;
        this.flightProviderCode = flightProviderCode;
        this.strategyCode = strategyCode;
    }

    @XmlElement
    public String getHotelProviderCode() {
        return hotelProviderCode;
    }

    public void setHotelProviderCode(String hotelProviderCode) {
        this.hotelProviderCode = hotelProviderCode;
    }

    @XmlElement
    public String getFlightProviderCode() {
        return flightProviderCode;
    }

    public void setFlightProviderCode(String flightProviderCode) {
        this.flightProviderCode = flightProviderCode;
    }

    @XmlElement
    public String getStrategyCode() {
        return strategyCode;
    }

    public void setStrategyCode(String strategyCode) {
        this.strategyCode = strategyCode;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof BookingConfigUpdateRequest) {
            BookingConfigUpdateRequest other = (BookingConfigUpdateRequest) obj;
            EqualsBuilder builder = new EqualsBuilder();
            builder.append(getHotelProviderCode(), other.getHotelProviderCode());
            builder.append(getFlightProviderCode(), other.getFlightProviderCode());
            return builder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();
        builder.append(getHotelProviderCode());
        builder.append(getFlightProviderCode());
        return builder.toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("hotelProvider", getHotelProviderCode()).
                append("flightProvider", getFlightProviderCode()).
                append("strategy", getStrategyCode()).
                toString();
    }

}
